package com.xs.tool.service.impl;

import com.xs.tool.dao.UserDao;
import com.xs.tool.model.User;
import com.xs.tool.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component("userService")
@Transactional
public class UserServiceImpl implements UserService {

	@Autowired
	UserDao userDao;

	@Override
	public User getOne(String userId) {
		if (null == userId || userId.equals("")) {
			return null;
		}
		Integer uid = Integer.parseInt(userId);
		return userDao.getOne(uid);
	}

	@Override
	public User findByName(String name) {
		if (null == name || name.equals("")) {
			return null;
		}
		User user = userDao.findByName(name);
		return user;
	}

	@Override
	public int updateUser(String token, Integer id) {
		return userDao.updateUser(token,id);
	}
}
